package AggregationMethod;

import java.util.ArrayList;

import Definitions.NodeClass;
import Sampling.SamplingAbstractClass;

/*****************************************************************
* Name : ModeMethod
* Aim : This class aims to keep the methods for the ModeMethod Neighborhood 
* Calculation Function type and inherited from the NeighbourhoodFunction *
* Algorithm : 1 2 3 0 5 -> 0 0 0 0 1
*****************************************************************/
public class ModeMethodClass extends NeighbourhoodFunctionAbstractClass {
	
	public ModeMethodClass(SamplingAbstractClass currentSampling){
		super(currentSampling);
		name ="ModeMethod";	
	}
	/*****************************************************************
	* Function Name: 	modeMethod
	* Aim: 				perform the ModeMethod
	* Inputs: 			ArrayList<Node> nodeList : The neighbors that will be used for the method
	* 					int usePredictOrActual : Predicted Classes or actual classes will be used 
	* 											when choosing neighbors
	* Outputs: 			countOfEdges
	* Data Structures:  ---
	* Algorithms: 		---
	*****************************************************************/
	public ArrayList<Double> getAggregatedNeighbourVector(ArrayList<NodeClass> nodeList)
	{
		ArrayList<Double> countOfEdges=new ArrayList<Double>();
		countOfEdges= this.countEdge(nodeList);
		
		double max = countOfEdges.get(0);
		for(int i = 1; i < countOfEdges.size(); i++)
		{
			if(countOfEdges.get(i) > max)
			{
				max = countOfEdges.get(i);
			}		 
		}
		if(max == 0)
		{
			for(int i = 0; i < countOfEdges.size(); i++)
			{
				countOfEdges.set(i,(double) 0);
			}
			return countOfEdges;
		}
		
		for(int i = 0; i < countOfEdges.size(); i++)
		{
			if(countOfEdges.get(i) == max)
			{
				countOfEdges.set(i, (double)1);
			}
			else
			{
				countOfEdges.set(i, (double)0);
			}
			
		}
		
		return countOfEdges;
	}
}
